{extend name="adminblue/base" /}
{block name="resources"/}

<style  type="text/css">
.modal-div{width:90%;margin:auto}
.modal-dl{overflow:hidden}
.modal-dl dt{line-height:33px;float:left;font-weight:400}
.modal-dl dd{float:left}
.modal-dl dd span{display:block;color:#de533c}
.btn.off{background-color:#e26f6f;color:#FFF}
.btn.sure{color:#FFF;background-color:#62c462}
.color-red{color:#f85606}
.color-green{color:#22c522}
.color-blue{color:#27a9e3}
.text-danger{color:#fb6b5b}

</style>

 {/block}
{block name="right_tab"}
<!-- <li><a class="nscs-table-handle_green" href="javascript:;" onclick="addBrand()"><i class="fa fa-plus-circle"></i>&nbsp;添加品牌</a></li> -->
{/block}
{block name="main"}
<table class="mytable">
	<tr>
		<th>
			角色：
			<select id="role" class="select-common middle">
				<option value="0">全部</option>
				<option value="1">推广员</option>
				<option value="2">股东</option>
				<option value="3">代理</option>
			</select>
			用户姓名：<input id="userName" class="input-common middle" type="text" value="">
			手机号：<input id="userTel" class="input-common middle" type="text" value="">
			<button onclick="searchData()" value="搜索" class="btn-common" >搜索</button>
		</th>		
	</tr>
</table>
<div class="mod-table">
	<div class="mod-table-head">
		<div class="con style0list">
			<table class="table-class">
				<colgroup>
					<col style="width: 8%;">
					<col style="width: 8%;">
					<col style="width: 8%;">
					<col style="width: 8%;">
					<col style="width: 8%;">
					<col style="width: 8%;">
					<col style="width: 8%;">
					<col style="width: 8%;">
					<col style="width: 8%;">
					<col style="width: 8%;">
					<col style="width: 8%;">
					<col style="width: 24%;">
				</colgroup>
				<thead>
					<tr>						
						<th>用户名称</th>					
						<th>是否是推广员</th>
						<th>是否是股东</th>
						<th>是否是代理</th>						
						<th>总佣金</th>
						<th>可提现佣金</th>
						<th>已提现佣金</th>
						<th>分销佣金</th>
						<th>股东分红</th>
						<th>股东全球分红</th>
						<th>区域代理佣金</th>
						<th>操作</th>
						<!-- <th>股东团队分红</th>
						<th>推广员团队分红</th>
						<th>渠道代理分红</th> -->
					</tr>
				</thead>

				<tbody></tbody>
			</table>
		</div>
	</div>
</div>




<!-- 修改用户上级（Modal）结束 -->
{/block}
{block name="script"}

<script type="text/javascript">	
	//查询
	function searchData(){
		LoadingInfo(1);
	}
	//加载数据
	function LoadingInfo(pageIndex) {
		var user_name = $("#userName").val();
		var user_phone = $("#userTel").val();
		var role = $("#role").val();
		$.ajax({
			type : "post",
			url : "{:__URL('ADMIN_MAIN/Commission/userAccountList')}",
			async : true,
			data : {
				"pageIndex" : pageIndex,
				"user_name":user_name,
				"user_phone":user_phone,
				"role":role
			},
			success : function(data) {
				$("#page_count").val(data["page_count"]);
				$("#pageNumber a").remove();
				var html = '';
				if (data["data"].length > 0) {
					for (var i = 0; i < data["data"].length; i++) {
						if(data["data"][i]["is_promoter"] ==1){
							var is_promoter = "<i class='fa fa-check text-success text-active'></i>";						
						}else{
							var is_promoter = "<i class='fa fa-times'></i>";		
						}
						if(data["data"][i]["is_partner"] ==1){
							var partner = '<a href="'+__URL('ADMIN_MAIN/Commission/useraccountrecordsdetail?type_id=4&uid='+data["data"][i]["uid"])+'" target="_blank">股东分红</a><a href="'+__URL('ADMIN_MAIN/Commission/useraccountrecordsdetail?type_id=5&uid='+data["data"][i]["uid"])+'" target="_blank">全球分红</a><br>';
							var is_partner = "<i class='fa fa-check text-success text-active'></i>";						
						}else{
							var partner = "";
							var is_partner = "<i class='fa fa-times'></i>";		
						}
						if(data["data"][i]["is_region_agent"] ==1){
							var region_agent = '<a href="'+__URL('ADMIN_MAIN/Commission/useraccountrecordsdetail?type_id=2&uid='+data["data"][i]["uid"])+'" target="_blank">代理佣金</a>';
							var is_region_agent = "<i class='fa fa-check text-success text-active'></i>";						
						}else{
							var region_agent = "";
							var is_region_agent = "<i class='fa fa-times'></i>";		
						}
						
						html += '<tr align="center">';	
						html += '<td>' + data["data"][i]["real_name"] + '</td>';
						
						html += '<td>' + is_promoter + '</td>';
						html += '<td>' + is_partner + '</td>';
						html += '<td>' + is_region_agent + '</td>';
						html += '<td class="color-red">' + parseFloat(data["data"][i]["commission"]).toFixed(2) + '</td>';
						html += '<td class="color-green">' + parseFloat(data["data"][i]["commission_cash"]).toFixed(2) + '</td>';
						html += '<td class="color-blue">' + parseFloat(data["data"][i]["commission_withdraw"]).toFixed(2) + '</td>';
						html += '<td>' + parseFloat(data["data"][i]["commission_promoter"]).toFixed(2) + '</td>';
						html += '<td>' + parseFloat(data["data"][i]["commission_partner"]).toFixed(2) + '</td>';
						html += '<td>' + parseFloat(data["data"][i]["commission_partner_global"]).toFixed(2) + '</td>';
						html += '<td>' + parseFloat(data["data"][i]["commission_region_agent"]).toFixed(2) + '</td>';
						
						html += '<td  align="left">';
						html += '<a href="'+__URL('ADMIN_MAIN/Commission/promoterAccount?uid='+data["data"][i]["uid"])+'" target="_blank">账户详情</a>';
							html += '<a href="'+__URL('ADMIN_MAIN/Commission/useraccountrecordsdetail?type_id=1&uid='+data["data"][i]["uid"])+'" target="_blank">分销佣金</a><br>'+partner+''+region_agent+'';
						html += '</td>';
					//	html += '<td>' + parseFloat(data["data"][i]["commission_partner_team"]).toFixed(2) + '</td>';
					//	html += '<td>' + parseFloat(data["data"][i]["commission_promoter_team"]).toFixed(2) + '</td>';
					//	html += '<td>' + parseFloat(data["data"][i]["commission_channelagent"]).toFixed(2) + '</td>';						
						html += '</tr>';
					}
				} else {
					html += '<tr align="center"><td colspan="12">暂无符合条件的数据记录</td></tr>';
				}
				
				$(".style0list tbody").html(html);
				var totalpage = $("#page_count").val();
				if (totalpage == 1) {
					changeClass("all");
				}
				initPageData(data["page_count"],data['data'].length,data['total_count']);
				var $html = pagenumShow(jumpNumber,totalpage,{$pageshow})
				$("#pageNumber").append($html);
			}
		});
	}	
	//全选
	function CheckAll(event){
		var checked = event.checked;
		$(".style0list tbody input[type = 'checkbox']").prop("checked",checked);
	}
	

</script>
{/block}